;
(function (window, angular) {
    'use strict';
    angular.module("Controller.Report.DirectOrdersNotDeliveredReport", [])
        .controller("DirectOrdersNotDeliveredReportCtrl", ["$scope", "$state", "ybWidget", "ybHttp", "MESG_TYPE", "$filter", "$timeout", "UserContextService", function ($scope, $state, ybWidget, ybHttp, MESG_TYPE, $filter, $timeout, UserContextService) {
            $scope.markInfo = {
                curRow: -1
            };
            $scope.pageInfo = {
                totalPages: 1,
                totalRows: 0,
                pageSize: 10,
                curPage: 1
            };
            $scope.toolbarConfig = {
                showColConfig: false
            };
            $scope.condition = {};
            $scope.dataList = [];
            $scope.tbConf = {
                scrollWidth: 1280,
                tableCol: [
                    {
                        name: "代理商采购单号",
                        dataField: "directSourceOrder",
                        width: 140,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "采购单号",
                        dataField: "billNo",
                        width: 170,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "行号",
                        dataField: "rowNo",
                        width: 170,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "零件编号",
                        dataField: "materialsNo",
                        width: 160,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "零件中文名",
                        dataField: "materialsDes",
                        width: 80,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "数量",
                        dataField: "qty",
                        width: 160,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "单价",
                        dataField: "price",
                        width: 110,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "总价",
                        dataField: "applyTotalPrice",
                        width: 90,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "收货方",
                        dataField: "deliveryOrgName",
                        width: 100,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "创建方",
                        dataField: "soldOrgName",
                        width: 100,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "收货地址",
                        dataField: "receiverAddress",
                        width: 100,
                        isShow: true,
                        isFixed: false,
                    },
                    {
                        name: "备注信息",
                        dataField: "remark",
                        width: 100,
                        isShow: true,
                        isFixed: false,
                    },
                ]
            };

            $scope.exportParam = {
                allUrl: ybHttp.RequestUrl("device", "/report/directPurchaseReportExport")
            };

            $scope.reset = function () {
                $scope.condition = {};
            };

            function getDataList(curPage) {
                $scope.markInfo.curRow = -1;
                var service = "device";
                var reqUrl = "/report/directPurchaseReport";

                if (!!curPage) {
                    $scope.pageInfo.curPage = curPage;
                }
                var param = {
                    pageSize: $scope.pageInfo.pageSize,
                    pageNum: $scope.pageInfo.curPage,
                    filters: angular.copy($scope.condition)
                };
                ybHttp.Post(service, reqUrl, param).then(function (resp) {
                    if (resp.code !== 0) {
                        ybWidget.ShowMessage(resp, MESG_TYPE.Error);
                        return;
                    }
                    angular.forEach(resp.value.list, function (item) {
                        item.sendStatusShow = $filter("ProgressStatus")(item.sendStatus, "inDepot");
                    });
                    $scope.pageInfo.totalRows = resp.value.total;
                    $scope.pageInfo.totalPages = resp.value.pages;
                    $scope.dataList = resp.value.list;
                });
            }

            $scope.switchToolbar = function (toolbar) {
                if (!!$scope.toolbarConfig["show" + toolbar]) {
                    $scope.toolbarConfig["show" + toolbar] = false;
                } else {
                    $timeout(function () {
                        $scope.toolbarConfig["show" + toolbar] = true;
                    });
                }
            };

            $scope.selectRow = function (index) {
                $scope.markInfo.curRow = index
            };

            $scope.search = function (curpage) {
                getDataList(curpage);
            };

            (function () {


            })();
        }])
    ;
})(window, window.angular);